package com.fas.system.domain;

import com.fas.common.core.domain.entity.SysUser;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.logging.log4j.util.Strings;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 巡检组对象 fas_inspection_group
 */
@ApiModel(value = "巡检组对象")
public class FasInspectionGroup implements Serializable {

    @ApiModelProperty(value = "巡检路线编号")
    private Integer groupCode	;//巡检路线编号

    @ApiModelProperty(value = "单位id")
    private Integer deptId	;//单位id

    @ApiModelProperty(value = "组长编号")
    private Integer groupLeaderId	;//组长编号

    @ApiModelProperty(value = "巡检组名称")
    private String groupName	;//巡检组名称

    @ApiModelProperty(value = "合作单位id")
    private Integer cooperationCompanyId; //合作单位id

    @JsonIgnore
    private String userStr	;//用户id数组（多个用户用英文都好隔开）

 /////////////非表结构数据//////////////////////
    private List<Integer> userList;
    private String groupLeaderName;//组长名称
    private String deptName;//单位名称
    private List<SysUser> fasIpqcList;//巡检员列表

    private String companyName; //合作单位名称
    private int lineNum;

    public Integer getGroupCode() {
        return groupCode;
    }

    public void setGroupCode(Integer groupCode) {
        this.groupCode = groupCode;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    public Integer getGroupLeaderId() {
        return groupLeaderId;
    }

    public void setGroupLeaderId(Integer groupLeaderId) {
        this.groupLeaderId = groupLeaderId;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getUserStr() {
        return userStr;
    }

    public void setUserStr(String userStr) {
        if(Strings.isNotBlank(userStr)){
            String[] split = userStr.split(",");
            this.userList = Stream.of(split).map(Integer::parseInt).collect(Collectors.toList());
        }
        this.userStr = userStr;
    }

    public List<Integer> getUserList() {
        return userList;
    }

    public void setUserList(List<Integer> userList) {
        if (!Objects.isNull(userList)){
            this.userStr = userList.stream().map(String::valueOf).collect(Collectors.joining(","));
        }
    }

    public String getGroupLeaderName() {
        return groupLeaderName;
    }

    public void setGroupLeaderName(String groupLeaderName) {
        this.groupLeaderName = groupLeaderName;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public List<SysUser> getFasIpqcList() {
        return fasIpqcList;
    }

    public void setFasIpqcList(List<SysUser> fasIpqcList) {
        this.fasIpqcList = fasIpqcList;
    }

    public int getLineNum() {
        return lineNum;
    }

    public void setLineNum(int lineNum) {
        this.lineNum = lineNum;
    }

    public Integer getCooperationCompanyId() {
        return cooperationCompanyId;
    }

    public void setCooperationCompanyId(Integer cooperationCompanyId) {
        this.cooperationCompanyId = cooperationCompanyId;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
}
